package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AlpContractStageDetail;
import com.ruoyi.system.service.IAlpContractStageDetailService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 阶段明细Controller
 * 
 * @author zhangjun
 * @date 2020-02-13
 */
@Controller
@RequestMapping("/system/stageDetail")
public class AlpContractStageDetailController extends BaseController
{
    private String prefix = "system/stageDetail";

    @Autowired
    private IAlpContractStageDetailService alpContractStageDetailService;

    @RequiresPermissions("system:stageDetail:view")
    @GetMapping()
    public String stageDetail()
    {
        return prefix + "/stageDetail";
    }

    /**
     * 查询阶段明细列表
     */
    @RequiresPermissions("system:stageDetail:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AlpContractStageDetail alpContractStageDetail)
    {
        startPage();
        List<AlpContractStageDetail> list = alpContractStageDetailService.selectAlpContractStageDetailList(alpContractStageDetail);
        return getDataTable(list);
    }

    /**
     * 导出阶段明细列表
     */
    @RequiresPermissions("system:stageDetail:export")
    @Log(title = "阶段明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AlpContractStageDetail alpContractStageDetail)
    {
        List<AlpContractStageDetail> list = alpContractStageDetailService.selectAlpContractStageDetailList(alpContractStageDetail);
        ExcelUtil<AlpContractStageDetail> util = new ExcelUtil<AlpContractStageDetail>(AlpContractStageDetail.class);
        return util.exportExcel(list, "stageDetail");
    }

    /**
     * 新增阶段明细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存阶段明细
     */
    @RequiresPermissions("system:stageDetail:add")
    @Log(title = "阶段明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AlpContractStageDetail alpContractStageDetail)
    {
        return toAjax(alpContractStageDetailService.insertAlpContractStageDetail(alpContractStageDetail));
    }

    /**
     * 修改阶段明细
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AlpContractStageDetail alpContractStageDetail = alpContractStageDetailService.selectAlpContractStageDetailById(id);
        mmap.put("alpContractStageDetail", alpContractStageDetail);
        return prefix + "/edit";
    }

    /**
     * 修改保存阶段明细
     */
    @RequiresPermissions("system:stageDetail:edit")
    @Log(title = "阶段明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AlpContractStageDetail alpContractStageDetail)
    {
        return toAjax(alpContractStageDetailService.updateAlpContractStageDetail(alpContractStageDetail));
    }

    /**
     * 删除阶段明细
     */
    @RequiresPermissions("system:stageDetail:remove")
    @Log(title = "阶段明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(alpContractStageDetailService.deleteAlpContractStageDetailByIds(ids));
    }
}
